************************************************************************************************************************
*  	Created By:	   	Richard Saunders 																		
*  	Creation Date: 	8/23/2020                                                                     	
*  	Purpose:     	Replication for: Only Friends Can Betray You: International Rivalry and Domestic Politics                                             	            
*   Dependencies: 	This .do file requires the ReLogit package by Gary King, available here: https://gking.harvard.edu/scholar_software/relogit-rare-events-logistic-regression/1-1-stata											 												      	
*	Version:		This analysis was run in Stata 15		
************************************************************************************************************************


********************************************
********************************************
******** Main Tables and Figures ***********
********************************************
********************************************

pwd

use "Saunders_2020_Replication_Data.dta", clear

drop if thompson_ongoing==1
drop if year <1950
drop if year >2005

gen rel = 0
replace rel =1 if contig==1
replace rel =1 if majpow1 ==1 | majpow2==1
drop if rel !=1


tab thompson_init Colgan_5yr, chi2 exp


***********************
******* Table 2 *******
***********************



eststo clear

use "Saunders_2020_Replication_Data.dta", clear

drop if thompson_ongoing==1
drop if year <1950
drop if year >2005

gen rel = 0
replace rel =1 if contig==1
replace rel =1 if majpow1 ==1 | majpow2==1
drop if rel !=1

sem (atop_defense s_un_glo fpolicysim dependweak <- X)
predict X, latent
predict shared_interests if e(sample), latent
label var shared_interests "sem(atop_defense s_un_glo fpolicysim dependweak)


label variable Colgan_5yr "Revolution"
label variable dependweak_Lag6 "Trade"
label variable fpolicysim_Lag6 "Policy"


 foreach varname in  shared_interests {

  by ccode1 ccode2 (year), sort:  gen `varname'_Lag6=`varname'[_n-6]
 }
 
 



logit thompson_init i.Colgan_5yr i.alliance_5yr c.fpolicysim_Lag6 c.dependweak_Lag6 revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 direct_contig Coldwar i.world_shock i.territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, cluster(dyad_id) 
eststo


logit thompson_init c.fpolicysim_Lag6##i.Colgan_5yr i.alliance_5yr c.dependweak_Lag6 revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 direct_contig Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, cluster(dyad_id)
eststo

*estimates store Policy


****************
*** Figure 1 ***
****************

margins, at(Colgan_5yr= (1) fpolicysim_Lag6= (.0025(.01)1)) 
marginsplot, recast(line) recastci(rarea) graphregion(color(white)) bgcolor(white) scheme(lean1)  ///
ytitle("Marginal Effect of Revolution") xtitle("Change in Policy Similarity") ci1opts(fintensity(40)) aspectratio(1.0) ///
yline(0) legend(on order( 1 "95% CI" ) region(color(white))) title("Figure 1: Effect of Revolution conditional on Policy Similarity") level(95) 


logit thompson_init i.Colgan_5yr##i.alliance_5yr c.fpolicysim_Lag6 c.dependweak_Lag6 revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 direct_contig Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, cluster(dyad_id) 
eststo


logit thompson_init c.dependweak_Lag6##i.Colgan_5yr i.alliance_5yr fpolicysim_Lag6 revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 direct_contig Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, cluster(dyad_id)
eststo

logit thompson_init c.shared_interests_Lag6##i.Colgan_5yr revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 direct_contig Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, cluster(dyad_id)
eststo


****************
*** Figure 2 ***
****************

margins, at(Colgan_5yr= (1) shared_interests_Lag6= (-.46(.01).40)) 
marginsplot, recast(line) recastci(rarea) graphregion(color(white)) bgcolor(white) scheme(lean1)  ///
ytitle("Marginal Effect of Revolution") xtitle("Change in Latent Interests") ci1opts(fintensity(40)) aspectratio(1.0) ///
yline(0) legend(on order( 1 "95% CI" ) region(color(white))) title("Figure 2: Effect of Revolution conditional on Shared Interests") level(95) 





esttab using "Table2.tex", label cells("b(star fmt(3))" se(par)) nobaselevels  replace starlevels(+ 0.10 * 0.05 ** 0.01 *** 0.001) title(Regression table\label{tab1})



********************************************
********************************************
**** Online Appendix Tables and Figures ****
********************************************
********************************************

*****************************
*** A5: Rare Events Logit ***
*****************************

eststo clear

use "Saunders_2020_Replication_Data.dta", clear

drop if thompson_ongoing==1
drop if year <1950
drop if year >2005

gen rel = 0
replace rel =1 if contig==1
replace rel =1 if majpow1 ==1 | majpow2==1
drop if rel !=1

sem (atop_defense s_un_glo fpolicysim dependweak <- X)
predict X, latent
predict shared_interests if e(sample), latent
label var shared_interests "sem(atop_defense s_un_glo fpolicysim dependweak)


 foreach varname in  shared_interests {

 by ccode1 ccode2 (year), sort:  gen `varname'_Lag6=`varname'[_n-6]
 }

gen fpolicysim_Lag6XColgan_5yr = fpolicysim_Lag6*Colgan_5yr
gen alliance_5yrXColgan_5yr = alliance_5yr*Colgan_5yr
gen dependweak_Lag6XColgan_5yr = dependweak_Lag6*Colgan_5yr
gen latentXColgan_5yr = shared_interests_Lag6*Colgan_5yr



relogit thompson_init Colgan_5yr fpolicysim_Lag6 alliance_5yr dependweak_Lag6 revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 direct_contig Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, cluster(dyad_id) 
eststo

relogit thompson_init fpolicysim_Lag6XColgan_5yr fpolicysim_Lag6 Colgan_5yr alliance_5yr dependweak_Lag6 revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 direct_contig Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, cluster(dyad_id)
eststo


relogit thompson_init alliance_5yrXColgan_5yr alliance_5yr Colgan_5yr fpolicysim_Lag6 dependweak_Lag6 revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 direct_contig Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, cluster(dyad_id) 
eststo

relogit thompson_init dependweak_Lag6XColgan_5yr dependweak_Lag6 Colgan_5yr fpolicysim_Lag6 revwar_5yr alliance_5yr cap_disparity_Lag6 level_democracy_Lag6 direct_contig  Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, cluster(dyad_id)
eststo 


relogit thompson_init latentXColgan_5yr Colgan_5yr shared_interests_Lag6 revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 direct_contig Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, cluster(dyad_id) 
eststo


esttab using "A5.tex", label cells("b(star fmt(3))" se(par)) nobaselevels  replace starlevels(+ 0.10 * 0.05 ** 0.01 *** 0.001) title(Regression table\label{tab1})

**************************
*** A6: Bivariate SOLS ***
**************************

use "Saunders_2020_Replication_Data.dta", clear

drop if thompson_ongoing==1
drop if year <1950
drop if year >2005

gen rel = 0
replace rel =1 if contig==1
replace rel =1 if majpow1 ==1 | majpow2==1
drop if rel !=1


tab thompson_init sols_5yr, chi2 exp


*************************
***** Tables A7-A10 *****
*** Window Robustness ***
*************************

eststo clear

use "Saunders_2020_Replication_Data.dta", clear
drop if thompson_ongoing==1
drop if year <1950
drop if year >2005

gen rel = 0
replace rel =1 if contig==1
replace rel =1 if majpow1 ==1 | majpow2==1
drop if rel !=1


destring dyad_id, replace
**************************
*** A7: Foreign Policy ***
**************************

rename Colgan_2yr revolution
rename fpolicysim_Lag3 policy
rename alliance_2yr alliance
rename dependweak_Lag3 depend
rename cap_disparity_Lag3 capdis
rename level_democracy_Lag3 democracy
rename thompson_peace_Lag3 peace1
rename thompson_peace2_Lag3  peace2
rename thompson_peace3_Lag3 peace3
rename revwar_2yr civilwar

logit thompson_init c.policy##i.revolution alliance depend civilwar capdis democracy direct_contig Coldwar world_shock territorial_dispute peace1 peace2 peace3, vce(cluster dyad_id) 
eststo

drop revolution
drop policy
drop alliance
drop depend
drop capdis
drop democracy
drop peace1
drop peace2
drop peace3
drop civilwar

rename Colgan_3yr revolution
rename fpolicysim_Lag4 policy
rename alliance_3yr alliance
rename dependweak_Lag4 depend
rename cap_disparity_Lag4 capdis
rename level_democracy_Lag4 democracy
rename thompson_peace_Lag4 peace1
rename thompson_peace2_Lag4  peace2
rename thompson_peace3_Lag4 peace3
rename revwar_3yr civilwar



logit thompson_init c.policy##i.revolution alliance depend civilwar capdis democracy direct_contig Coldwar world_shock territorial_dispute peace1 peace2 peace3, vce(cluster dyad_id) 
eststo

drop revolution
drop policy
drop alliance
drop depend
drop capdis
drop democracy
drop peace1
drop peace2
drop peace3
drop civilwar


rename Colgan_4yr revolution
rename fpolicysim_Lag5 policy
rename alliance_4yr alliance
rename dependweak_Lag5 depend
rename cap_disparity_Lag5 capdis
rename level_democracy_Lag5 democracy
rename thompson_peace_Lag5 peace1
rename thompson_peace2_Lag5  peace2
rename thompson_peace3_Lag5 peace3
rename revwar_4yr civilwar


logit thompson_init c.policy##i.revolution alliance depend civilwar capdis democracy direct_contig Coldwar world_shock territorial_dispute peace1 peace2 peace3, vce(cluster dyad_id) 
eststo

drop revolution
drop policy
drop alliance
drop depend
drop capdis
drop democracy
drop peace1
drop peace2
drop peace3
drop civilwar


rename Colgan_5yr revolution
rename fpolicysim_Lag6 policy
rename alliance_5yr alliance
rename dependweak_Lag6 depend
rename cap_disparity_Lag6 capdis
rename level_democracy_Lag6 democracy
rename thompson_peace_Lag6 peace1
rename thompson_peace2_Lag6  peace2
rename thompson_peace3_Lag6 peace3
rename revwar_5yr civilwar


logit thompson_init c.policy##i.revolution alliance depend civilwar capdis democracy direct_contig Coldwar world_shock territorial_dispute peace1 peace2 peace3, vce(cluster dyad_id) 
eststo

drop revolution
drop policy
drop alliance
drop depend
drop capdis
drop democracy
drop peace1
drop peace2
drop peace3
drop civilwar


rename Colgan_6yr revolution
rename fpolicysim_Lag7 policy
rename alliance_6yr alliance
rename dependweak_Lag7 depend
rename cap_disparity_Lag7 capdis
rename level_democracy_Lag7 democracy
rename thompson_peace_Lag7 peace1
rename thompson_peace2_Lag7  peace2
rename thompson_peace3_Lag7 peace3
rename revwar_6yr civilwar


logit thompson_init c.policy##i.revolution alliance depend civilwar capdis democracy direct_contig Coldwar world_shock territorial_dispute peace1 peace2 peace3, vce(cluster dyad_id) 
eststo

drop revolution
drop policy
drop alliance
drop depend
drop capdis
drop democracy
drop peace1
drop peace2
drop peace3
drop civilwar


rename Colgan_7yr revolution
rename fpolicysim_Lag8 policy
rename alliance_7yr alliance
rename dependweak_Lag8 depend
rename cap_disparity_Lag8 capdis
rename level_democracy_Lag8 democracy
rename thompson_peace_Lag8 peace1
rename thompson_peace2_Lag8  peace2
rename thompson_peace3_Lag8 peace3
rename revwar_7yr civilwar


logit thompson_init c.policy##i.revolution alliance depend civilwar capdis democracy direct_contig Coldwar world_shock territorial_dispute peace1 peace2 peace3, vce(cluster dyad_id) 
eststo

drop revolution
drop policy
drop alliance
drop depend
drop capdis
drop democracy
drop peace1
drop peace2
drop peace3
drop civilwar


rename Colgan_8yr revolution
rename fpolicysim_Lag9 policy
rename alliance_8yr alliance
rename dependweak_Lag9 depend
rename cap_disparity_Lag9 capdis
rename level_democracy_Lag9 democracy
rename thompson_peace_Lag9 peace1
rename thompson_peace2_Lag9  peace2
rename thompson_peace3_Lag9 peace3
rename revwar_8yr civilwar



logit thompson_init c.policy##i.revolution alliance depend civilwar capdis democracy direct_contig Coldwar world_shock territorial_dispute peace1 peace2 peace3, vce(cluster dyad_id) 
eststo



esttab using "A7.tex", label cells("b(star fmt(3))" se(par)) nobaselevels  replace starlevels(+ 0.10 * 0.05 ** 0.01 *** 0.001) title(Regression table\label{tab1})



****************************
*** A8: Foreign Alliance ***
****************************

eststo clear


use "Saunders_2020_Replication_Data.dta", clear
drop if thompson_ongoing==1
drop if year <1950
drop if year >2005

gen rel = 0
replace rel =1 if contig==1
replace rel =1 if majpow1 ==1 | majpow2==1
drop if rel !=1



rename Colgan_2yr revolution
rename fpolicysim_Lag3 policy
rename alliance_2yr alliance
rename dependweak_Lag3 depend
rename cap_disparity_Lag3 capdis
rename level_democracy_Lag3 democracy
rename thompson_peace_Lag3 peace1
rename thompson_peace2_Lag3  peace2
rename thompson_peace3_Lag3 peace3
rename revwar_2yr civilwar



logit thompson_init i.alliance##i.revolution  policy depend civilwar capdis democracy direct_contig Coldwar world_shock territorial_dispute peace1 peace2 peace3, vce(cluster dyad_id) 
eststo

drop revolution
drop policy
drop alliance
drop depend
drop capdis
drop democracy
drop peace1
drop peace2
drop peace3
drop civilwar


rename Colgan_3yr revolution
rename fpolicysim_Lag4 policy
rename alliance_3yr alliance
rename dependweak_Lag4 depend
rename cap_disparity_Lag4 capdis
rename level_democracy_Lag4 democracy
rename thompson_peace_Lag4 peace1
rename thompson_peace2_Lag4  peace2
rename thompson_peace3_Lag4 peace3
rename revwar_3yr civilwar


logit thompson_init i.alliance##i.revolution  policy depend civilwar capdis democracy direct_contig Coldwar world_shock territorial_dispute peace1 peace2 peace3, vce(cluster dyad_id) 
eststo

drop revolution
drop policy
drop alliance
drop depend
drop capdis
drop democracy
drop peace1
drop peace2
drop peace3
drop civilwar


rename Colgan_4yr revolution
rename fpolicysim_Lag5 policy
rename alliance_4yr alliance
rename dependweak_Lag5 depend
rename cap_disparity_Lag5 capdis
rename level_democracy_Lag5 democracy
rename thompson_peace_Lag5 peace1
rename thompson_peace2_Lag5  peace2
rename thompson_peace3_Lag5 peace3
rename revwar_4yr civilwar


logit thompson_init i.alliance##i.revolution  policy depend civilwar capdis democracy direct_contig Coldwar world_shock territorial_dispute peace1 peace2 peace3, vce(cluster dyad_id) 
eststo

drop revolution
drop policy
drop alliance
drop depend
drop capdis
drop democracy
drop peace1
drop peace2
drop peace3
drop civilwar


rename Colgan_5yr revolution
rename fpolicysim_Lag6 policy
rename alliance_5yr alliance
rename dependweak_Lag6 depend
rename cap_disparity_Lag6 capdis
rename level_democracy_Lag6 democracy
rename thompson_peace_Lag6 peace1
rename thompson_peace2_Lag6  peace2
rename thompson_peace3_Lag6 peace3
rename revwar_5yr civilwar


logit thompson_init i.alliance##i.revolution  policy depend civilwar capdis democracy direct_contig Coldwar world_shock territorial_dispute peace1 peace2 peace3, vce(cluster dyad_id) 
eststo

drop revolution
drop policy
drop alliance
drop depend
drop capdis
drop democracy
drop peace1
drop peace2
drop peace3
drop civilwar


rename Colgan_6yr revolution
rename fpolicysim_Lag7 policy
rename alliance_6yr alliance
rename dependweak_Lag7 depend
rename cap_disparity_Lag7 capdis
rename level_democracy_Lag7 democracy
rename thompson_peace_Lag7 peace1
rename thompson_peace2_Lag7  peace2
rename thompson_peace3_Lag7 peace3
rename revwar_6yr civilwar


logit thompson_init i.alliance##i.revolution  policy depend civilwar capdis democracy direct_contig Coldwar world_shock territorial_dispute peace1 peace2 peace3, vce(cluster dyad_id) 
eststo

drop revolution
drop policy
drop alliance
drop depend
drop capdis
drop democracy
drop peace1
drop peace2
drop peace3
drop civilwar


rename Colgan_7yr revolution
rename fpolicysim_Lag8 policy
rename alliance_7yr alliance
rename dependweak_Lag8 depend
rename cap_disparity_Lag8 capdis
rename level_democracy_Lag8 democracy
rename thompson_peace_Lag8 peace1
rename thompson_peace2_Lag8  peace2
rename thompson_peace3_Lag8 peace3
rename revwar_7yr civilwar


logit thompson_init i.alliance##i.revolution  policy depend civilwar capdis democracy direct_contig Coldwar world_shock territorial_dispute peace1 peace2 peace3, vce(cluster dyad_id) 
eststo

drop revolution
drop policy
drop alliance
drop depend
drop capdis
drop democracy
drop peace1
drop peace2
drop peace3
drop civilwar


rename Colgan_8yr revolution
rename fpolicysim_Lag9 policy
rename alliance_8yr alliance
rename dependweak_Lag9 depend
rename cap_disparity_Lag9 capdis
rename level_democracy_Lag9 democracy
rename thompson_peace_Lag9 peace1
rename thompson_peace2_Lag9  peace2
rename thompson_peace3_Lag9 peace3
rename revwar_8yr civilwar


logit thompson_init i.alliance##i.revolution  policy depend civilwar capdis democracy direct_contig Coldwar world_shock territorial_dispute peace1 peace2 peace3, vce(cluster dyad_id) 
eststo


esttab using "A8.tex", label cells("b(star fmt(3))" se(par)) nobaselevels  replace starlevels(+ 0.10 * 0.05 ** 0.01 *** 0.001) title(Regression table\label{tab1})



***************************
*** A9: Trade Dependence***
***************************

eststo clear


use "Saunders_2020_Replication_Data.dta", clear

drop if thompson_ongoing==1
drop if year <1950
drop if year >2005

gen rel = 0
replace rel =1 if contig==1
replace rel =1 if majpow1 ==1 | majpow2==1
drop if rel !=1


rename Colgan_2yr revolution
rename fpolicysim_Lag3 policy
rename alliance_2yr alliance
rename dependweak_Lag3 depend
rename cap_disparity_Lag3 capdis
rename level_democracy_Lag3 democracy
rename thompson_peace_Lag3 peace1
rename thompson_peace2_Lag3  peace2
rename thompson_peace3_Lag3 peace3
rename revwar_2yr civilwar

 
logit thompson_init c.depend##i.revolution  policy alliance civilwar capdis democracy direct_contig Coldwar world_shock territorial_dispute peace1 peace2 peace3, vce(cluster dyad_id) 
eststo

drop revolution
drop policy
drop alliance
drop depend
drop capdis
drop democracy
drop peace1
drop peace2
drop peace3
drop civilwar


rename Colgan_3yr revolution
rename fpolicysim_Lag4 policy
rename alliance_3yr alliance
rename dependweak_Lag4 depend
rename cap_disparity_Lag4 capdis
rename level_democracy_Lag4 democracy
rename thompson_peace_Lag4 peace1
rename thompson_peace2_Lag4  peace2
rename thompson_peace3_Lag4 peace3
rename revwar_3yr civilwar


logit thompson_init c.depend##i.revolution  policy alliance civilwar capdis democracy direct_contig Coldwar world_shock territorial_dispute peace1 peace2 peace3, vce(cluster dyad_id) 
eststo

drop revolution
drop policy
drop alliance
drop depend
drop capdis
drop democracy
drop peace1
drop peace2
drop peace3
drop civilwar


rename Colgan_4yr revolution
rename fpolicysim_Lag5 policy
rename alliance_4yr alliance
rename dependweak_Lag5 depend
rename cap_disparity_Lag5 capdis
rename level_democracy_Lag5 democracy
rename thompson_peace_Lag5 peace1
rename thompson_peace2_Lag5  peace2
rename thompson_peace3_Lag5 peace3
rename revwar_4yr civilwar


logit thompson_init c.depend##i.revolution  policy alliance civilwar capdis democracy direct_contig Coldwar world_shock territorial_dispute peace1 peace2 peace3, vce(cluster dyad_id) 
eststo

drop revolution
drop policy
drop alliance
drop depend
drop capdis
drop democracy
drop peace1
drop peace2
drop peace3
drop civilwar


rename Colgan_5yr revolution
rename fpolicysim_Lag6 policy
rename alliance_5yr alliance
rename dependweak_Lag6 depend
rename cap_disparity_Lag6 capdis
rename level_democracy_Lag6 democracy
rename thompson_peace_Lag6 peace1
rename thompson_peace2_Lag6  peace2
rename thompson_peace3_Lag6 peace3
rename revwar_5yr civilwar


logit thompson_init c.depend##i.revolution  policy alliance civilwar capdis democracy direct_contig Coldwar world_shock territorial_dispute peace1 peace2 peace3, vce(cluster dyad_id) 
eststo

drop revolution
drop policy
drop alliance
drop depend
drop capdis
drop democracy
drop peace1
drop peace2
drop peace3
drop civilwar


rename Colgan_6yr revolution
rename fpolicysim_Lag7 policy
rename alliance_6yr alliance
rename dependweak_Lag7 depend
rename cap_disparity_Lag7 capdis
rename level_democracy_Lag7 democracy
rename thompson_peace_Lag7 peace1
rename thompson_peace2_Lag7  peace2
rename thompson_peace3_Lag7 peace3
rename revwar_6yr civilwar


logit thompson_init c.depend##i.revolution  policy alliance civilwar capdis democracy direct_contig Coldwar world_shock territorial_dispute peace1 peace2 peace3, vce(cluster dyad_id) 
eststo

drop revolution
drop policy
drop alliance
drop depend
drop capdis
drop democracy
drop peace1
drop peace2
drop peace3
drop civilwar


rename Colgan_7yr revolution
rename fpolicysim_Lag8 policy
rename alliance_7yr alliance
rename dependweak_Lag8 depend
rename cap_disparity_Lag8 capdis
rename level_democracy_Lag8 democracy
rename thompson_peace_Lag8 peace1
rename thompson_peace2_Lag8  peace2
rename thompson_peace3_Lag8 peace3
rename revwar_7yr civilwar


logit thompson_init c.depend##i.revolution  policy alliance civilwar capdis democracy direct_contig Coldwar world_shock territorial_dispute peace1 peace2 peace3, vce(cluster dyad_id) 
eststo

drop revolution
drop policy
drop alliance
drop depend
drop capdis
drop democracy
drop peace1
drop peace2
drop peace3
drop civilwar


rename Colgan_8yr revolution
rename fpolicysim_Lag9 policy
rename alliance_8yr alliance
rename dependweak_Lag9 depend
rename cap_disparity_Lag9 capdis
rename level_democracy_Lag9 democracy
rename thompson_peace_Lag9 peace1
rename thompson_peace2_Lag9  peace2
rename thompson_peace3_Lag9 peace3
rename revwar_8yr civilwar


logit thompson_init c.depend##i.revolution  policy alliance civilwar capdis democracy direct_contig Coldwar world_shock territorial_dispute peace1 peace2 peace3, vce(cluster dyad_id) 
eststo


esttab using "A9.tex", label cells("b(star fmt(3))" se(par)) nobaselevels  replace starlevels(+ 0.10 * 0.05 ** 0.01 *** 0.001) title(Regression table\label{tab1})


****************************
*** A10: Latent Interests ***
****************************
eststo clear


use "Saunders_2020_Replication_Data.dta", clear

drop if thompson_ongoing==1
drop if year <1950
drop if year >2005

gen rel = 0
replace rel =1 if contig==1
replace rel =1 if majpow1 ==1 | majpow2==1
drop if rel !=1

sem (atop_defense s_un_glo fpolicysim dependweak <- X)
predict X, latent
predict shared_interests if e(sample), latent
label var shared_interests "sem(atop_defense s_un_glo fpolicysim dependweak)


 foreach varname in shared_interests {

 forvalues i=1/9 {
  
     by ccode1 ccode2 (year), sort:  gen `varname'_Lag`i'=`varname'[_n-`i']
  }
}
drop shared_interests


rename Colgan_2yr revolution
rename fpolicysim_Lag3 policy
rename alliance_2yr alliance
rename dependweak_Lag3 depend
rename cap_disparity_Lag3 capdis
rename level_democracy_Lag3 democracy
rename thompson_peace_Lag3 peace1
rename thompson_peace2_Lag3  peace2
rename thompson_peace3_Lag3 peace3
rename shared_interests_Lag3 shared_interests
rename revwar_2yr civilwar

 
logit thompson_init c.shared_interests##i.revolution depend policy alliance civilwar capdis democracy direct_contig Coldwar world_shock territorial_dispute peace1 peace2 peace3, vce(cluster dyad_id) 
eststo

drop revolution
drop policy
drop alliance
drop depend
drop capdis
drop democracy
drop peace1
drop peace2
drop peace3
drop shared_interests
drop civilwar


rename Colgan_3yr revolution
rename fpolicysim_Lag4 policy
rename alliance_3yr alliance
rename dependweak_Lag4 depend
rename cap_disparity_Lag4 capdis
rename level_democracy_Lag4 democracy
rename thompson_peace_Lag4 peace1
rename thompson_peace2_Lag4  peace2
rename thompson_peace3_Lag4 peace3
rename shared_interests_Lag4 shared_interests
rename revwar_3yr civilwar


logit thompson_init c.shared_interests##i.revolution depend policy alliance civilwar capdis democracy direct_contig Coldwar world_shock territorial_dispute peace1 peace2 peace3, vce(cluster dyad_id) 
eststo

drop revolution
drop policy
drop alliance
drop depend
drop capdis
drop democracy
drop peace1
drop peace2
drop peace3
drop shared_interests
drop civilwar


rename Colgan_4yr revolution
rename fpolicysim_Lag5 policy
rename alliance_4yr alliance
rename dependweak_Lag5 depend
rename cap_disparity_Lag5 capdis
rename level_democracy_Lag5 democracy
rename thompson_peace_Lag5 peace1
rename thompson_peace2_Lag5  peace2
rename thompson_peace3_Lag5 peace3
rename shared_interests_Lag5 shared_interests
rename revwar_4yr civilwar


logit thompson_init c.shared_interests##i.revolution depend policy alliance civilwar capdis democracy direct_contig Coldwar world_shock territorial_dispute peace1 peace2 peace3, vce(cluster dyad_id) 
eststo

drop revolution
drop policy
drop alliance
drop depend
drop capdis
drop democracy
drop peace1
drop peace2
drop peace3
drop shared_interests
drop civilwar


rename Colgan_5yr revolution
rename fpolicysim_Lag6 policy
rename alliance_5yr alliance
rename dependweak_Lag6 depend
rename cap_disparity_Lag6 capdis
rename level_democracy_Lag6 democracy
rename thompson_peace_Lag6 peace1
rename thompson_peace2_Lag6  peace2
rename thompson_peace3_Lag6 peace3
rename shared_interests_Lag6 shared_interests
rename revwar_5yr civilwar


logit thompson_init c.shared_interests##i.revolution depend policy alliance civilwar capdis democracy direct_contig Coldwar world_shock territorial_dispute peace1 peace2 peace3, vce(cluster dyad_id) 
eststo

drop revolution
drop policy
drop alliance
drop depend
drop capdis
drop democracy
drop peace1
drop peace2
drop peace3
drop shared_interests
drop civilwar


rename Colgan_6yr revolution
rename fpolicysim_Lag7 policy
rename alliance_6yr alliance
rename dependweak_Lag7 depend
rename cap_disparity_Lag7 capdis
rename level_democracy_Lag7 democracy
rename thompson_peace_Lag7 peace1
rename thompson_peace2_Lag7  peace2
rename thompson_peace3_Lag7 peace3
rename shared_interests_Lag7 shared_interests
rename revwar_6yr civilwar


logit thompson_init c.shared_interests##i.revolution depend policy alliance civilwar capdis democracy direct_contig Coldwar world_shock territorial_dispute peace1 peace2 peace3, vce(cluster dyad_id) 
eststo

drop revolution
drop policy
drop alliance
drop depend
drop capdis
drop democracy
drop peace1
drop peace2
drop peace3
drop shared_interests
drop civilwar


rename Colgan_7yr revolution
rename fpolicysim_Lag8 policy
rename alliance_7yr alliance
rename dependweak_Lag8 depend
rename cap_disparity_Lag8 capdis
rename level_democracy_Lag8 democracy
rename thompson_peace_Lag8 peace1
rename thompson_peace2_Lag8  peace2
rename thompson_peace3_Lag8 peace3
rename shared_interests_Lag8 shared_interests
rename revwar_7yr civilwar


logit thompson_init c.shared_interests##i.revolution depend policy alliance civilwar capdis democracy direct_contig Coldwar world_shock territorial_dispute peace1 peace2 peace3, vce(cluster dyad_id) 
eststo

drop revolution
drop policy
drop alliance
drop depend
drop capdis
drop democracy
drop peace1
drop peace2
drop peace3
drop shared_interests
drop civilwar


rename Colgan_8yr revolution
rename fpolicysim_Lag9 policy
rename alliance_8yr alliance
rename dependweak_Lag9 depend
rename cap_disparity_Lag9 capdis
rename level_democracy_Lag9 democracy
rename thompson_peace_Lag9 peace1
rename thompson_peace2_Lag9  peace2
rename thompson_peace3_Lag9 peace3
rename shared_interests_Lag9 shared_interests
rename revwar_8yr civilwar


logit thompson_init c.shared_interests##i.revolution depend  policy alliance  civilwar capdis democracy direct_contig Coldwar world_shock territorial_dispute peace1 peace2 peace3, vce(cluster dyad_id) 
eststo


esttab using "A10.tex", label cells("b(star fmt(3))" se(par)) nobaselevels  replace starlevels(+ 0.10 * 0.05 ** 0.01 *** 0.001) title(Regression table\label{tab1})




******************************
***** A11: CHISOLS models *****
******************************

eststo clear

use "Saunders_2020_Replication_Data.dta", clear

drop if thompson_ongoing==1
drop if year <1950
drop if year >2005

gen rel = 0
replace rel =1 if contig==1
replace rel =1 if majpow1 ==1 | majpow2==1
drop if rel !=1

sem (atop_defense s_un_glo fpolicysim dependweak <- X)
predict X, latent
predict shared_interests if e(sample), latent
label var shared_interests "sem(atop_defense s_un_glo fpolicysim dependweak)


 foreach varname in  shared_interests {
  by ccode1 ccode2 (year), sort:  gen `varname'_Lag6=`varname'[_n-6]
 }


destring dyad_id, replace

logit thompson_init i.sols_5yr fpolicysim_Lag6 alliance_5yr dependweak_Lag6 revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 direct_contig Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, vce(cluster dyad_id) 
eststo


logit thompson_init c.fpolicysim_Lag6##i.sols_5yr alliance_5yr dependweak_Lag6 revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 direct_contig Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, vce(cluster dyad_id) 
eststo

gen allianceXsols = sols_5yr*alliance_5yr
logit thompson_init allianceXsols sols_5yr alliance_5yr dependweak_Lag6 fpolicysim_Lag6 revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 direct_contig Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, vce(cluster dyad_id) 
eststo


logit thompson_init c.dependweak_Lag6##i.sols_5yr alliance_5yr fpolicysim_Lag6 revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 direct_contig Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, vce(cluster dyad_id) 
eststo 

logit thompson_init c.shared_interests_Lag6##i.sols_5yr i.alliance_5yr c.dependweak_Lag6 c.fpolicysim_Lag6 revwar_5yr c.cap_disparity_Lag6 c.level_democracy_Lag6 i.direct_contig i.Coldwar i.world_shock i.territorial_dispute c.thompson_peace_Lag6 c.thompson_peace2_Lag6 c.thompson_peace3_Lag6, vce(cluster dyad_id) 
eststo

esttab using "A11.tex", label cells("b(star fmt(3))" se(par)) nobaselevels  replace starlevels(+ 0.10 * 0.05 ** 0.01 *** 0.001) title(Regression table\label{tab1})


**************************************
*** A16: Logit Consensus Rivalries ***
**************************************

eststo clear

use "Saunders_2020_Replication_Data.dta", clear


drop if thompson_ongoing==1
drop if year <1950
drop if year >2005



gen rel = 0
replace rel =1 if contig==1
replace rel =1 if majpow1 ==1 | majpow2==1
drop if rel !=1

sem (atop_defense s_un_glo fpolicysim dependweak <- X)
predict X, latent
predict shared_interests if e(sample), latent
label var shared_interests "sem(atop_defense s_un_glo fpolicysim dependweak)


 foreach varname in  shared_interests {
* generate lagged variables for all variables in the variable list 
  by ccode1 ccode2 (year), sort:  gen `varname'_Lag6=`varname'[_n-6]
 }

destring dyad_id, replace

logit joint_thompson i.Colgan_5yr fpolicysim_Lag6 i.alliance_5yr dependweak_Lag6 revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, vce(cluster dyad_id) 
eststo


logit joint_thompson c.fpolicysim_Lag6##i.Colgan_5yr i.alliance_5yr dependweak_Lag6 revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, vce(cluster dyad_id) 
eststo


logit joint_thompson i.Colgan_5yr##i.alliance_5yr dependweak_Lag6 fpolicysim_Lag6 revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, vce(cluster dyad_id) 
eststo


logit joint_thompson c.dependweak_Lag6##i.Colgan_5yr i.alliance_5yr fpolicysim_Lag6 revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, vce(cluster dyad_id) 
eststo 

logit joint_thompson c.shared_interests_Lag6##i.Colgan_5yr i.alliance_5yr fpolicysim_Lag6 dependweak_Lag6 revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, vce(cluster dyad_id) 
eststo 


esttab using "A16.tex", label cells("b(star fmt(3))" se(par)) nobaselevels  replace starlevels(+ 0.10 * 0.05 ** 0.01 *** 0.001) title(Regression table\label{tab1})





************************************
********* Tables A12-A15 ***********
******* Threshold Robustness *******
************************************
eststo clear

*********************
*** A12: Alliance ***
*********************
use "Saunders_2020_Replication_Data.dta", clear

drop if thompson_ongoing==1
drop if year <1950
drop if year >2005

gen rel = 0
replace rel =1 if contig==1
replace rel =1 if majpow1 ==1 | majpow2==1
drop if rel !=1


destring dyad_id, replace

gen rev1_5yrXalliance_5yr = rev1_5yr*alliance_5yr
logit thompson_init rev1_5yrXalliance_5yr rev1_5yr i.alliance_5yr dependweak_Lag6 fpolicysim_Lag6 revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, vce(cluster dyad_id) 
eststo

gen rev2_5yrXalliance_5yr = rev2_5yr*alliance_5yr
logit thompson_init rev2_5yrXalliance_5yr rev2_5yr i.alliance_5yr dependweak_Lag6 fpolicysim_Lag6 revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, vce(cluster dyad_id) 
eststo


logit thompson_init rev3_5yr##i.alliance_5yr dependweak_Lag6 fpolicysim_Lag6 revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, vce(cluster dyad_id) 
eststo



logit thompson_init rev4_5yr##i.alliance_5yr dependweak_Lag6 fpolicysim_Lag6 revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, vce(cluster dyad_id) 
eststo

gen rev5_5yrXalliance_5yr = rev5_5yr*alliance_5yr
logit thompson_init rev5_5yrXalliance_5yr rev5_5yr alliance_5yr dependweak_Lag6 fpolicysim_Lag6 revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, vce(cluster dyad_id) 
eststo

gen rev6_5yrXalliance_5yr = rev6_5yr*alliance_5yr

logit thompson_init rev6_5yrXalliance_5yr rev6_5yr i.alliance_5yr dependweak_Lag6 fpolicysim_Lag6 revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, vce(cluster dyad_id) 
eststo

esttab using "A12.tex", label cells("b(star fmt(3))" se(par)) nobaselevels  replace starlevels(+ 0.10 * 0.05 ** 0.01 *** 0.001) title(Regression table\label{tab1})


***************************
*** A13: Foreign Policy ***
***************************

eststo clear

use "Saunders_2020_Replication_Data.dta", clear

drop if thompson_ongoing==1
drop if year <1950
drop if year >2005

gen rel = 0
replace rel =1 if contig==1
replace rel =1 if majpow1 ==1 | majpow2==1
drop if rel !=1


destring dyad_id, replace

logit thompson_init c.fpolicysim_Lag6##rev1_5yr alliance_5yr dependweak_Lag6 revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, vce(cluster dyad_id)  
eststo


logit thompson_init c.fpolicysim_Lag6##rev2_5yr alliance_5yr dependweak_Lag6 revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, vce(cluster dyad_id)  
eststo

logit thompson_init c.fpolicysim_Lag6##rev3_5yr alliance_5yr dependweak_Lag6 revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, vce(cluster dyad_id)  
eststo


logit thompson_init c.fpolicysim_Lag6##rev4_5yr alliance_5yr dependweak_Lag6 revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, vce(cluster dyad_id) 
eststo


logit thompson_init c.fpolicysim_Lag6##rev5_5yr alliance_5yr dependweak_Lag6 revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, vce(cluster dyad_id) 
eststo


logit thompson_init c.fpolicysim_Lag6##rev6_5yr alliance_5yr dependweak_Lag6 revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, vce(cluster dyad_id) 
eststo

esttab using "A13.tex", label cells("b(star fmt(3))" se(par)) nobaselevels  replace starlevels(+ 0.10 * 0.05 ** 0.01 *** 0.001) title(Regression table\label{tab1})



****************************
******** A14: Trade ********
****************************

eststo clear

use "Saunders_2020_Replication_Data.dta", clear

drop if thompson_ongoing==1
drop if year <1950
drop if year >2005

gen rel = 0
replace rel =1 if contig==1
replace rel =1 if majpow1 ==1 | majpow2==1
drop if rel !=1


destring dyad_id, replace

logit thompson_init c.dependweak_Lag6##rev1_5yr fpolicysim_Lag6 alliance_5yr revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, vce(cluster dyad_id) 
eststo


logit thompson_init c.dependweak_Lag6##rev2_5yr fpolicysim_Lag6 alliance_5yr revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, vce(cluster dyad_id) 
eststo

logit thompson_init c.dependweak_Lag6##rev3_5yr fpolicysim_Lag6 alliance_5yr revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, vce(cluster dyad_id)
eststo


logit thompson_init c.dependweak_Lag6##rev4_5yr fpolicysim_Lag6 alliance_5yr revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, vce(cluster dyad_id)
eststo


logit thompson_init c.dependweak_Lag6##rev5_5yr fpolicysim_Lag6 alliance_5yr revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, vce(cluster dyad_id)
eststo



logit thompson_init c.dependweak_Lag6##rev6_5yr fpolicysim_Lag6 alliance_5yr revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, vce(cluster dyad_id)
eststo

esttab using "A14.tex", label cells("b(star fmt(3))" se(par)) nobaselevels  replace starlevels(+ 0.10 * 0.05 ** 0.01 *** 0.001) title(Regression table\label{tab1})


***************************************
******** A15: Latent Interests ********
***************************************

eststo clear

use "Saunders_2020_Replication_Data.dta", clear

drop if thompson_ongoing==1
drop if year <1950
drop if year >2005

gen rel = 0
replace rel =1 if contig==1
replace rel =1 if majpow1 ==1 | majpow2==1
drop if rel !=1


sem (atop_defense s_un_glo fpolicysim dependweak <- X)
predict X, latent
predict shared_interests if e(sample), latent
label var shared_interests "sem(atop_defense s_un_glo fpolicysim dependweak)


 foreach varname in  shared_interests {
* generate lagged variables for all variables in the variable list 
  by ccode1 ccode2 (year), sort:  gen `varname'_Lag6=`varname'[_n-6]
 }



destring dyad_id, replace

logit thompson_init c.shared_interests_Lag6##rev1_5yr dependweak_Lag6 fpolicysim_Lag6 alliance_5yr revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, vce(cluster dyad_id) 
eststo


logit thompson_init c.shared_interests_Lag6##rev2_5yr dependweak_Lag6 fpolicysim_Lag6 alliance_5yr revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, vce(cluster dyad_id) 
eststo

logit thompson_init c.shared_interests_Lag6##rev3_5yr dependweak_Lag6 fpolicysim_Lag6 alliance_5yr revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, vce(cluster dyad_id)
eststo


logit thompson_init c.shared_interests_Lag6##rev4_5yr dependweak_Lag6 fpolicysim_Lag6 alliance_5yr revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, vce(cluster dyad_id)
eststo


logit thompson_init c.shared_interests_Lag6##rev5_5yr dependweak_Lag6 fpolicysim_Lag6 alliance_5yr revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, vce(cluster dyad_id)
eststo



logit thompson_init c.shared_interests_Lag6##rev6_5yr dependweak_Lag6 fpolicysim_Lag6 alliance_5yr revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, vce(cluster dyad_id)
eststo

esttab using "A15.tex", label cells("b(star fmt(3))" se(par)) nobaselevels  replace starlevels(+ 0.10 * 0.05 ** 0.01 *** 0.001) title(Regression table\label{tab1})



********************************************************
******* A16 & A17: Necessary Condition Framework *******
********************************************************

use "Appendix Data1.dta",clear



gen shared_interest = 0
replace shared_interest = 1 if alliance_5yr ==1
replace shared_interest = 1 if majortradedy ==1
replace shared_interest = 1 if majorpolicydy ==1


drop if thompson_init == 0
drop if year <1950
drop if year >2005


*A16*
tab sols_5yr shared_interest, chi2 exp
*A17*
tab Colgan_5yr shared_interest, chi2 exp




***************************************
*** A18: Main models, dropping Iran ***
***************************************


eststo clear

use "Saunders_2020_Replication_Data.dta", clear

drop if thompson_ongoing==1
drop if year <1950
drop if year >2005

gen rel = 0
replace rel =1 if contig==1
replace rel =1 if majpow1 ==1 | majpow2==1
drop if rel !=1


drop if ccode1 == 630
drop if ccode2 == 630


sem (atop_defense s_un_glo fpolicysim dependweak <- X)
predict X, latent
predict shared_interests if e(sample), latent
label var shared_interests "sem(atop_defense s_un_glo fpolicysim dependweak)


label variable Colgan_5yr "Revolution"
label variable dependweak_Lag6 "Trade"
label variable fpolicysim_Lag6 "Policy"


 foreach varname in  shared_interests {
* generate lagged variables for all variables in the variable list 
  by ccode1 ccode2 (year), sort:  gen `varname'_Lag6=`varname'[_n-6]
 }


logit thompson_init i.Colgan_5yr i.alliance_5yr c.fpolicysim_Lag6 c.dependweak_Lag6 revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 direct_contig Coldwar i.world_shock i.territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, cluster(dyad_id) 
eststo


logit thompson_init c.fpolicysim_Lag6##i.Colgan_5yr i.alliance_5yr c.dependweak_Lag6 revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 direct_contig Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, cluster(dyad_id)
eststo

estimates store Policy

logit thompson_init i.Colgan_5yr##i.alliance_5yr c.fpolicysim_Lag6 c.dependweak_Lag6 revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 direct_contig Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, cluster(dyad_id) 
eststo


logit thompson_init c.dependweak_Lag6##i.Colgan_5yr i.alliance_5yr fpolicysim_Lag6 revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 direct_contig Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, cluster(dyad_id)
eststo 

logit thompson_init c.shared_interests_Lag6##i.Colgan_5yr revwar_5yr cap_disparity_Lag6 level_democracy_Lag6 direct_contig Coldwar world_shock territorial_dispute thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, cluster(dyad_id)
eststo

estimates store Interests




esttab using "A18.tex", label cells("b(star fmt(3))" se(par)) nobaselevels  replace starlevels(+ 0.10 * 0.05 ** 0.01 *** 0.001) title(Regression table\label{tab1})




**************************************************
*** A14: Main Models Dropping Unbalanced Dyads ***
**************************************************


eststo clear

use "Saunders_2020_Replication_Data.dta", clear

drop if thompson_ongoing==1
drop if year <1950
drop if year >2005



gen rel = 0
replace rel =1 if contig==1
replace rel =1 if majpow1 ==1 | majpow2==1
drop if rel !=1

drop if majpow1 ==1 & majpow2==0
drop if majpow1 ==0 & majpow2 ==1


sem (atop_defense s_un_glo fpolicysim dependweak <- X)
predict X, latent
predict shared_interests if e(sample), latent
label var shared_interests "sem(atop_defense s_un_glo fpolicysim dependweak)


label variable Colgan_5yr "Revolution"
label variable dependweak_Lag6 "Trade"
label variable fpolicysim_Lag6 "Policy"


 foreach varname in  shared_interests {
* generate lagged variables for all variables in the variable list 
  by ccode1 ccode2 (year), sort:  gen `varname'_Lag6=`varname'[_n-6]
 }


 logit thompson_init  Colgan_5yr c.fpolicysim_Lag6 i.alliance_5yr c.dependweak_Lag6 revwar_5yr cap_disparity_Lag6 direct_contig territorial_dispute level_democracy_Lag6 Coldwar world_shock thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, cluster(dyad_id)
eststo


logit thompson_init c.fpolicysim_Lag6##i.Colgan_5yr i.alliance_5yr c.dependweak_Lag6 revwar_5yr cap_disparity_Lag6 direct_contig territorial_dispute level_democracy_Lag6 Coldwar world_shock thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, cluster(dyad_id)
eststo




estimates store Policy

logit thompson_init i.Colgan_5yr##i.alliance_5yr c.fpolicysim_Lag6 c.dependweak_Lag6 revwar_5yr cap_disparity_Lag6 direct_contig territorial_dispute level_democracy_Lag6 Coldwar world_shock thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, cluster(dyad_id) 
eststo


logit thompson_init c.dependweak_Lag6##i.Colgan_5yr i.alliance_5yr fpolicysim_Lag6 revwar_5yr cap_disparity_Lag6 direct_contig territorial_dispute level_democracy_Lag6 Coldwar world_shock thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, cluster(dyad_id)
eststo 


logit thompson_init c.shared_interests_Lag6##i.Colgan_5yr revwar_5yr cap_disparity_Lag6 direct_contig territorial_dispute level_democracy_Lag6 Coldwar world_shock thompson_peace_Lag6 thompson_peace2_Lag6 thompson_peace3_Lag6, cluster(dyad_id)
eststo




esttab using "A14.tex", label cells("b(star fmt(3))" se(par)) nobaselevels  replace starlevels(+ 0.10 * 0.05 ** 0.01 *** 0.001) title(Regression table\label{tab1})






*************************************************
*** A15: Models with Count of Rivalries as DV ***
*************************************************


use "Appendix Data2.dta", clear



eststo clear
reg rivalrycount five_year cap_Lag6 polity2_Lag6 territorialdisp_Lag6 civilwar_Lag6 coldwar systemshock, cluster(ccode1)
eststo

reg rivalrycount sols_five_year cap_Lag6 polity2_Lag6 territorialdisp_Lag6 civilwar_Lag6 coldwar systemshock, cluster(ccode1)
eststo

esttab using "A15.tex", label cells("b(star fmt(3))" se(par)) nobaselevels  replace starlevels(+ 0.10 * 0.05 ** 0.01 *** 0.001) title(Regression table\label{tab1})



